<?php
$appid = 98;
$device_id = inputFilter($_REQUEST['device_id']);
$device_type = inputFilter($_REQUEST['device_type']);
$act_callback_url = $_REQUEST['act_callback_url'];
$reg_callback_url = $_REQUEST['reg_callback_url'];

if(empty($device_id)){
    echo json_encode(array('status'=>'1'));exit;
}
$time = time();
$cid = '1';//爱神马
$wheresql = 'where 1=1';
$wheresql .= " and device_id = '$device_id'";
$re1 = getonerecord("select * from tttj.asm_kd_record $wheresql and status = 1");
$re2 = getonerecord("select * from tttj.asm_kd_record $wheresql and status = 0");
if($re1 || $re2){
    echo json_encode(array('status'=>'2'));exit;
}else{
    $sql = "insert into tttj.asm_kd_record (`device_id`,`device_type`,`cid`,`act_callback_url`,`reg_callback_url`,`ctime`,`status`,`appid`) VALUES ('$device_id','$device_type','1','$act_callback_url','$reg_callback_url','$time',0,'$appid')";
    exec_db($sql);
    echo json_encode(array('status'=>'0'));exit;
}

?>

